package com.common.service.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.common.service.TestService;

public class TestManytoOneServiceImpl extends HibernateDaoSupport implements TestService{
	
	public void addObject(Object obj){
		this.getSession().save(obj);
	}
	
	public Object findObject(Class objclass,Long id){
		return this.getHibernateTemplate().getSessionFactory().getCurrentSession().get(objclass, id);
	}
	
	public List findAll(Class objclass){
		String hql = "from "+objclass.getSimpleName();
		return this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(hql).list();
	}

	public void updateObject(Object obj) {
		this.getHibernateTemplate().getSessionFactory().getCurrentSession().saveOrUpdate(obj);
	}

	public void removeObject(Object obj) {
		this.getHibernateTemplate().getSessionFactory().getCurrentSession().delete(obj);
	}
}
